package com.lin.genericstest;
/**
 * 泛型
 * @author Zhang
 *
 * @param <T>
 */
public class GenericsBaseDemo<T> {
	private T var;
	
	public GenericsBaseDemo(T var) {
		this.var = var;
	}

	public GenericsBaseDemo() {
		this.var = var;
	}
	public T getVar() {
		return var;
	}

	public void setVar(T var) {
		this.var = var;
	}
	
	public static void main(String[] args) {
		GenericsBaseDemo<String> gTest = new GenericsBaseDemo<String>();
		gTest.setVar("Hello");
		System.out.println("String:"+gTest.var);
		GenericsBaseDemo<Integer> gTest2 = new GenericsBaseDemo<Integer>();
		gTest2.setVar(100);
		System.out.println("Integer:"+gTest2.var);
		GenericsBaseDemo genericsTest = new GenericsBaseDemo();
		genericsTest.setVar(false);
		System.out.println("Boolean:"+genericsTest.var);
		GenericsBaseDemo genericsTest2 = new GenericsBaseDemo<>(3.1415926);
		System.out.println("Float:"+genericsTest2.var);
	}
}
